﻿using Autofac;
using Autofac.Integration.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.Mvc;

namespace APJ.ComLib.WebApp.IoCContainer
{
    public class IocConfig
    {
        public static void RegisterDependencies()
        {
            var builder = new ContainerBuilder();
            SetupResolveRules(builder);
            builder.RegisterControllers(Assembly.GetExecutingAssembly());
            var container = builder.Build();
            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
        }
        /// <summary>
        /// 配置注册依赖注入的接口
        /// </summary>
        /// <param name="builder"></param>
        private static void SetupResolveRules(ContainerBuilder builder)
        {
            //builder.RegisterType<BL.SqlContext>().As<BL.IDatabeseContext>();
            //builder.RegisterType<UserHelper>().As<IUserHelper>();
            //builder.RegisterType<CookiesHelper>().As<ICookiesHelper>();
            //builder.RegisterType<FaxDocxHelper>().As<IFaxDocxHelper>();
            //builder.RegisterType<SMSHelper>().As<ISMSHelper>();
            //builder.RegisterType<ADWrapper>().As<IADBase>();
            //builder.RegisterType<UserServer>().As<IUserServer>();
            //builder.RegisterType<MailWrapper>().As<IMailBase>();
            //builder.RegisterType<CreatePermit>().As<ICreatePermit>();
            //builder.RegisterType<SearchPermit>().As<ISearchPermit>();
            //builder.RegisterType<CheckInPermit>().As<ICheckInPermit>();
            //builder.RegisterType<CheckOutPermit>().As<ICheckOutPermit>();
            //builder.RegisterType<SystemCheck>().As<ISystemCheck>();
            //builder.RegisterModule<AutofacWebTypesModule>();
            //builder.RegisterType<SiteInOrOutHistoryServer>().As<ISiteInOrOutHistoryServer>();
            //builder.RegisterType<MenuServer>().As<IMenuServer>();
            //builder.RegisterType<BL.CommonDataProvide>().As<BL.ICommonDataProvide>();
            //builder.RegisterType<DailyActivePermit>().As<IDailyActivePermit>();
            //builder.RegisterType<SMSService>().As<ISMSService>();
        }
    }
}